/*
 * @Description: 
 * @Author: handongliang dongliang.han@12301.cn
 * @Date: 2023-09-12 15:31:45
 * @LastEditTime: 2023-11-09 17:24:06
 */
import type { RadioChangeEvent } from 'antd';
import { Radio } from 'antd';
import React from "react";

const RadioChange: React.FC<{
    options?: { label: string, value: any }[],
    defaultValue?: any,
    size?: 'large' | 'middle' | 'small',
    onSubmit?: (e: any) => void
}> = (props) => {
    const {
        options = [
            { label: '景区旅游', value: '景区旅游' },
            { label: '餐饮', value: '餐饮' },
            { label: '旅游交通', value: '旅游交通' },
        ],
        size = 'middle',
        defaultValue = '景区旅游',
        onSubmit = () => {
        },
    } = props;

    const onChangeRadio = (e: RadioChangeEvent) => {
        const value = e.target.value;
        onSubmit(value);
    };

    return (
        <Radio.Group prefixCls={`dp-radio`} size={size} onChange={onChangeRadio} defaultValue={defaultValue} buttonStyle="solid">
            {options?.map((item: any) => {
                return (
                    <Radio.Button prefixCls={`dp-radio`} value={item.value} key={item.label + item.value}>
                        {item.label}
                    </Radio.Button>
                );
            })}
        </Radio.Group>
    );
};
export default RadioChange;
